#ifndef BLUETOOTHCLIENT_H
#define BLUETOOTHCLIENT_H

#include <QObject>
#include <QDebug>

#include <qbluetoothserviceinfo.h>

#include "servicemanager.h"
#include "networkmessage.h"

QTM_BEGIN_NAMESPACE
class QBluetoothSocket;
QTM_END_NAMESPACE

QTM_USE_NAMESPACE

class BluetoothClient : public QObject
{
Q_OBJECT
public:
    BluetoothClient();
    ~BluetoothClient();

    Q_INVOKABLE void discoverService();
    Q_INVOKABLE void startClient(const QBluetoothServiceInfo &remoteService);
    Q_INVOKABLE void stopClient();

public slots:
     Q_INVOKABLE void sendMessage(const QString &message);

 signals:
     void messageReceived(QString message);
     void socketConnected(QBluetoothSocket*);
     void socketDisconnected();
     void noServiceFound();

 private slots:
     void readSocket();
     void connected();
     void disconnected();

     void serviceReady();

 private:
     QBluetoothSocket *socket;
     ServiceManager serviceManager;
};

#endif // BLUETOOTHCLIENT_H
